<?php
include_once(dirname(__FILE__).'\domain\Person.php');
include_once(dirname(__FILE__).'\database\dbPersons.php');
include_once(dirname(__FILE__).'\domain\Booking.php');
include_once(dirname(__FILE__).'\database\dbBookings.php');
?>

<html>
<body>

<img src="images/rmhlogo3.gif" alt="rmh logo" 
     align = "left" width="90" height="140"/>

<h1 style="text-align:center ; font-family:Georgia"> Ronald McDonald House Referral Form</h1>
<h3 style="text-align:center ; font-family:Georgia "> 250 Brackett Street, Portland Maine 04102 Phone: (207) 780-6282</h3>
<h5 style="text-align:center ; font-family:Georgia"> Families should call on the day of arrival <br /> 
                                                     for room availability and confirmation </h5>
<br />
<br />
<?php 
if ($_POST['submit'] != 'Submit')
    include ('blankForm.inc');
else{ 
    
  echo("Thank you, your form has been submitted for review by the house manager.");

  $primaryGuest = new Person($_POST["last_name"], $_POST["first_name"], 
                             $_POST['address'], $_POST['city'],$_POST['state'], $_POST['zip'],
                             $_POST['phone1'], $_POST['phone2'], $_POST['email'], "guest",
                             $_POST['patient_name'],$_POST['patient_birthdate'],$_POST['patient_relation'],"");

  insert_dbPersons($primaryGuest);
  
  $date = getDate();
  $pendingBooking = new Booking($date[year].'-'.$date[month].'-'.$date[mday], 
                                $primaryGuest->get_id(), $_POST['patient_name'], 
                                "", "", $_POST['social_worker'], $_POST['hospital']);
  
  for($count = 1 ; $count <= 4 ; $count += 1){
      if($_POST['additional_guest'.$count] != "")
         $pendingBooking->add_occupant($_POST['additional_guest'.$count], $_POST['additional_guest'.$count.'_relation']);
  }
  
  insert_dbBookings($pendingBooking);
}
?>
</body>
</html>